<?
include_once "../../persistobject/userdesc.lib";
include_once "viewlayout.lib";
include_once "userpub.lib";


$userDesc = new CUserDesc();

$viewLayout = new CViewLayout($userDesc, getenv("DOCUMENT_ROOT")."/admin/user/layoutdesc/viewlayoutdesc.xml", $_GET["ID"]);
$viewLayout->editUrl = "useredit.php";
$viewLayout->viewUrl = "userview.php";
$viewLayout->listUrl = "userlist.php";

$userViewToolBox = GetToolBox();
foreach($viewLayout->getViewCommonTools() as $toolItem)
{
	$userViewToolBox->siteBoxItems[] = $toolItem;
}
$toolItem = new CSideBoxItem("", "", "");
$userViewToolBox->siteBoxItems[] = $toolItem;
$toolItem = new CSideBoxItem("/admin/img/clearpass.gif", "Clear Password", "", "clearPassword();");
$userViewToolBox->siteBoxItems[] = $toolItem;

$layoutFactory = new CLayoutFactoryAdmin();
$layoutFactory->setActiveTab("TM_2");
//$layoutFactory->addSideBox(GetSubMenuBox());
$layoutFactory->addSideBox($userViewToolBox);
$content = $viewLayout->layout();

$header = $layoutFactory->getHeader();
$tail = $layoutFactory->getTail();
$body = $layoutFactory->getBody($content);

$js = createJs();

echo $header.$js.$body.$tail;

function createJs()
{
	$js = '
		<script>
			function clearPassword()
			{
				var xmlHttp = GetAJAXObject();
				xmlHttp.open("GET", "clearpassword.php?ID='.$_GET["ID"].'",false);
				xmlHttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
				xmlHttp.send(null);
				var ret = xmlHttp.responseText+"";
				xmlHttp = null;
				var res = eval("("+ret+")");
				if (res == 1)
					alert("Clear Password Sucess!");
				else
					alert("Clear Password failure!");
			}
		</script>
		';
	return $js;
}
?>
